/*
 * @Author: qin
 * @Date:   2018-08-28
 * +----------------------------------------------------------------------
 * | admin [ 后台管理系统公共配置信息 ]
 * | 图纸上传相关接口方法
 * +----------------------------------------------------------------------
 */
layui.define(['configure', 'configureCom', 'dataFormat'], function (exports) {
    var configure = layui.configure;
    var configureCom = layui.configureCom;
    var dataFormat = layui.dataFormat;
    var drawing = {
        //获取专业列表
        getSpecialtyList: function (data) {
            data.singleProjectId = data.singleProjectId;
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.DRWAING_SPECIALTY_LIST_HTTP, data).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.result});
                }, function (err) {
                    reject({code: 0, msg: '', result: {}});
                });
            });
        },
        //获取所有专业列表（不分勘察设计）
        getAllSpecialtyList: function (data) {
            data.singleProjId = data.singleProjectId;
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.DRWAING_ALL_SPECIALTY_LIST_HTTP, data).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: res.result});
                }, function (err) {
                    reject({code: 0, msg: '', result: {}});
                });
            });
        },
        //获取图纸列表
        getDrawList: function (data) {
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.DRWAING_LIST_HTTP, data).then(function (res) {
                    var data = dataFormat.drawingDataInit(res.result);

                    resolve({code: res.code, msg: res.msg, result: data});
                }, function (err) {
                    reject({code: 0, msg: '', result: {}});
                });
            });
        },
        //获取图纸列表(不区分勘察设计)
        getDrawAllList: function (data) {
            data.singleProjId = data.singleProjectId;
            data.specialtyId = data.speciatyId;
            return new Promise(function (resolve, reject) {
                configureCom.getAjax(configure.DRWAING_ALL_LIST_HTTP, data).then(function (res) {
                    var data = dataFormat.drawingDataInit(res.result);

                    resolve({code: res.code, msg: res.msg, result: data});
                }, function (err) {
                    reject({code: 0, msg: '', result: {}});
                });
            });
        },
        //删除
        deleteDrawing: function (data) {
            return new Promise(function (resolve, reject) {
                configureCom.postDataAjax(configure.DRWAING_DELETE_HTTP, data).then(function (res) {
                    resolve({code: res.code, msg: res.msg, result: data});
                }, function (err) {
                    reject({code: 0, msg: '', result: {}});
                });
            });
        }
    };
    exports('drawing', drawing);
});